package dane.brown.sql.checker.service.model;

import lombok.Data;

import java.util.regex.Pattern;

@Data
public class CheckRule {
    Pattern pattern;
    String regex;
    String errorMsg;
    String suggestion;

    // 默认构造函数，用于Spring Boot配置绑定
    public CheckRule() {
    }

    public CheckRule(String regex, String errorMsg, String suggestion) {
        this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        this.errorMsg = errorMsg;
        this.suggestion = suggestion;
    }
    
    // 当设置regex属性时，自动编译pattern
    public void setRegex(String regex) {
        this.regex = regex;
        this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
    }
}
